package demo.propertySupport;

/**
 * description: <br>
 * createTime: 2021/1/13 17:41 <br>
 *
 * @author zzh
 */
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;


public class SomeBeanPropertyListener implements PropertyChangeListener,VetoableChangeListener
{
    public void propertyChange(PropertyChangeEvent evt)
    {
        System.out.println("\""+evt.getNewValue() +"\" is setted to replace the old value \""+evt.getOldValue()+"\"");
    }

    public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
    {
        if(evt.getNewValue().equals("invalidValue")){
            System.out.println("\""+evt.getNewValue() +"\" is try to replace the old value \""+evt.getOldValue()+"\"");
            throw new PropertyVetoException("What you set \"invalidValue\"is a invalid value! operate fail!", evt);
        }
    }
}
